home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
comm
/
misc
/
zvm1_25.lha
/
handlerecordconversation.zvm
< prev
next >
Wrap
Text File
|
1993-09-27
|
14KB
|
502 lines
/*handlerecordconversation.zvm*/
/* DANGER!!! DO NOT EDIT ANYTHING THAT IS NOT PART OF THE USER-CODE SECTION!!! */
/* THIS PART IS INCLUDED FROM INCLUDEH.ZVM. DO NOT EDIT THIS PART. LOOK FOR
THE SECTION WHICH SAYS USER CODE SECTION. YOU HAVE BEEN WARNED!
V1.00
*/
/* we want results! */
options results
/* We want to trap on these things, to help us debug. The definitions for
these are in INLCUDET.ZVM
*/
signal on halt
signal on novalue
signal on syntax
signal on break_c
/* Set up modem stuff */
call doInitializations
/* We are about to start the user code section. Any function that you
write that has a PROCEDURE statement NEEDS to have an EXPOSE MODE. STATUS.
for my stub functions to work.
*/
/*vvvvvvvvvvvvvvvvvvvvvvvvBEGINNING OF USER CODEvvvvvvvvvvvvvvvvvvvvvvvvvv*/
status = handleVoice()
/* finish up */
call flushPhoneBuffer()
/* make sure zvm doesn't hang up or anything, so we send
him a listen */
call listen()
exit 20
handleVoice: procedure expose status. mode.
status = status.Normal;
actualTime = date('s') || time('s')
/* make a unique file name for our incoming message */
fileName = 'voice:voicein/zvm' || actualTime
call flushPhoneBuffer()
call time('R') /* reset ellapsed timer */
status = recordVoice(fileName)
handle = addLogEntry(0)
call setLogEntryVariable('FILENAME', 0, handle, fileName)
call setLogEntryVariable('LENGTH', 0, handle, trunc(time('E')))
call setLogEntryVariable('COMMENT', 0, handle, 'Recorded Manually')
call setLogEntryVariable('TYPE', 0, handle, 'v') /* voice file */
/*
call setLogEntryVariable('CIDNAME', 0, handle, currentCIDName())
call setLogEntryVariable('CIDNUMBER', 0, handle, currentCIDNumber())
*/
return status
/*^^^^^^^^^^^^^^^^^^^^^^^^^^END OF USER CODE^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/*-------------------------------HANDS OFF--------------------------------*/
/* DON'T TOUCH THIS STUFF. IF YOU FIX SOMETHING HERE, TELL ME ABOUT IT */
/*
HISTORY
V1.32 - Added getoption, readoptions, setserial
V1.31 - Fixed debugger stuff (no value)
V1.30 - Added debugger stuff
V1.29 - Fixed type. and log. problem not being exposed
- Fixed filetype function
V1.28 - Fixed a problem in callup. Maybe related to 5.02 roms
V1.27 - Added filetype rexx function to determine the type
of a file
V1.26 - Added some more rexx functions to interface with ZVM
- Added the callup function to dial a telephone number
V1.25 - Fixed getnumvoicemessages
V1.24 - Added requiremode, assumemode, etc.
V1.23 - Changed the way type and status are handled and added
a new argument to the get and set stuff (namely, the log number)
- Also changed to setLogEntryVariable and getLogEntryVariable
instead of the numerous functions we had before
V1.22 - Added stuff to make it more programmable
*/
exit
getOption: procedure expose options.
parse upper arg optionName
return options.optionName
readOptions: procedure expose options.
firstLine = sourceline(1)
parse var firstLine '/*' title '.'
optionsFileName = title || '.options'
if exists(optionsFileName) then do
call open('options', optionsFileName, 'r')
do while ~eof('options')
line = readln('options')
parse upper var line variable '=' value
options.variable = value
end
call close('options')
end
return
/* this function dials a number and returns status.normal
if someone picks up the phone that was called. It returns
other types of errors otherwise.
*/
callup: procedure expose status. mode. device.
parse arg telephoneNumber
/* should do an at+fclass=8 */
status = requireMode(mode.voiceMode)
if status ~= status.normal then return status
status = writeLine('ATD' telephoneNumber)
if status ~= status.normal then return status
/* this should swallow the thing we just sent out */
status = readLine(60) /* 60 second timeout */
if status ~= status.normal then return status
ringing:
status = readLine(60) /* 60 second timeout */
if status ~= status.normal then return status
/* line should have the line we want */
if line = 'VCON' then do
/* removed the next line because even though we received
a VCON, it doesn't go into voicemode */
call requireDevice(device.telephoneLine)
/*
call assumeMode(mode.connectedMode)
*/
return status.normal
end
if line = 'RINGING' then signal ringing
if line = 'NO CARRIER' then return status.busydetected
if line = '' then signal ringing
if line = 'NO DIALTONE' then do
call showDebugger("I couldn't detect the dialtone")
return status.busydetected
end
return status.busyDetected
/* This function gives you a simple way of presenting an N key menu
to the caller
ARGS: numKeys choiceFileName badChoiceFileName timeOut validChoices
numBadChoices
numKeys = number of keys wanted
choiceFileName = file name of the menu
badChoiceFileName = what to say if caller enters a bad choice
timeOut = number of seconds allowed before timing out
validChoices = list of characters that are valid choices
numBadChoices = number of times you want to present the menu before exiting
RETURNS: status, choice = valid key
*/
presentMenu: procedure expose choice status. mode.
parse arg numKeys,choiceFileName,badChoiceFileName,timeOut,validChoices,numBadChoices .
timesAround = numBadChoices;
do timesAround = numBadChoices to 1 by -1
status = playVoice(choiceFileName)
if status > status.keyDetected then signal presentMenuDone;
status = readNKeys(numKeys, timeOut)
if status = status.timedOut then do
call flushPhoneBuffer()
status = playVoice('voice:voices/Timed Out')
iterate
end
if status ~= status.normal then signal presentMenuDone;
choice = keys
if pos(choice, validChoices) = 0 then do
call flushPhoneBuffer()
status = playVoice(badChoiceFileName)
iterate
end
return status.normal
end
status = status.timedOut
presentMenuDone:
return status
/*----------------------------------------------------------------------*/
/* Here are the encapsulated functions. They're responsible for
communicating with ZVM. Don't edit or touch them, except for
bug fixes.
*/
playVoice: procedure expose status. mode.
parse arg fileName
address voicemail1 'playVoice' fileName
if rc >= status.busyDetected then
call showDebugger('playVoice' rc)
return rc
/* this returns a handle to the newly created log entry */
addLogEntry: procedure expose status. mode.
if arg() ~= 1 then do
say 'Bad arguments to addLogEntry'
return 20
end
parse arg logNumber
address voicemail1 'addLogEntry' logNumber
return result
setLogEntryVariable: procedure expose status. mode.
if arg() ~= 4 then do
say 'Bad arguments to setLogEntryVariable'
return 20
end
parse arg variable, logNumber, logEntryNumber, logEntryValue
address voicemail1 'setLogEntryVar' variable ',' || logNumber || ',' || logEntryNumber || ',' || logEntryValue
return rc
getLogEntryVariable: procedure expose status. mode.
if arg() ~= 3 then do
say 'Bad arguments to getLogEntryVariable'
return 'BADBADBAD'
end
parse arg variable, logNumber, logEntryNumber
address voicemail1 'getLogEntryVar' variable ',' || logNumber || ',' || logEntryNumber
return result
getNumVoiceMessages: procedure expose status. mode.
if arg() ~= 1 then do
say 'Bad arguments to getNumVoiceMessages'
return 'BADBADBAD'
end
parse arg logNumber
address voicemail1 'getNumVoiceMessages' logNumber
return result
recordVoice: procedure expose status. mode.
parse arg fileName
address voicemail1 'recordVoice' fileName
return rc
password: procedure expose status. mode.
address voicemail1 'password'
return result
hasFax: procedure expose status. mode.
address voicemail1 'hasfax'
return result
playBeep: procedure expose status. mode.
parse arg tone1, tone2, duration
address voicemail1 'playBeep' tone1 ',' tone2 ',' duration
return rc
readNKeys: procedure expose status. keys mode.
parse arg numKeys, timeOut
address voicemail1 'readNKeys' numKeys ',' timeOut
if rc = status.normal then keys = result
return rc
read1Key: procedure expose status. key mode.
parse arg timeOut
address voicemail1 'read1Key' timeOut
if rc = status.normal then key = result
return rc
readKeysUntil: procedure expose status. keys mode.
parse arg terminatingCharacter, maxCharacters, timeOut
address voicemail1 'readKeysUntil' terminatingCharacter ',' maxCharacters ',' timeOut
if rc = status.normal then keys = result
return rc
readLine: procedure expose status. line mode.
parse arg timeOut
address voicemail1 'readLine' timeOut
if rc = status.normal then line = result
return rc
quickATCommand: procedure expose status. mode.
parse arg command, timeout, errorLine
if arg(2, 'o') then timeout = 5
if arg(3, 'o') then errorLine = 'ERROR'
rc = writeLine(command)
if rc ~= status.normal then return rc
rc = readLine(timeout)
if rc ~= status.normal then return rc
rc = readLine(timeout)
if line = errorLine then return status.error
return rc
writeLine: procedure expose status. mode.
parse arg line
address voicemail1 'writeLine' line
return rc
/* the 'assumeUnknownMode' is to make sure that any use of a voice command WILL
cause ZVM to hang up the line, reset the modem, then do its stuff */
dropLine: procedure expose status. mode.
address voicemail1 'requireMode' mode.commandMode
address voicemail1 'assumeUnknownMode'
return rc
atCommands: procedure expose status. mode.
address voicemail1 'requireMode' mode.connectedMode
address voicemail1 'assumeUnknownMode'
return rc
requireDevice: procedure expose status. mode.
parse arg device
address voicemail1 'requireDevice' device
return rc
requireCompression: procedure expose status. compression.
parse arg compression
address voicemail1 'requireCompression' compression
return rc
requireMode: procedure expose status. mode.
parse arg mode
address voicemail1 'requireMode' mode
return rc
assumeMode: procedure expose status. mode.
parse arg mode
address voicemail1 'assumeMode' mode
return rc
assumeUnknownMode: procedure expose status. mode.
address voicemail1 'assumeUnknownMode'
return rc
distinctiveRing: procedure expose status. mode.
address voicemail1 'distinctiveRing'
return result
currentCIDName: procedure expose status. mode.
address voicemail1 'currentCIDName'
return result
currentCIDNumber: procedure expose status. mode.
address voicemail1 'currentCIDNumber'
return result
fileType: procedure expose status. mode.
parse arg filename
address voicemail1 'filetype' filename
return result
/* handshaking = 1 if you want 7 wire handshaking, handshaking = 2 if you
want xon/xoff handshaking */
changeSerialParameters: procedure expose status. mode.
parse arg bps, bits, stop, handshaking
address voicemail1 'setserial' bps ',' bits ',' stop ',' handshaking
return rc
/* this is mainly for fax mode */
use19200: procedure expose status. mode.
call changeSerialParameters(19200, 8, 1, 1)
address voicemail1 'assumeUnknownMode'
return rc
flushPhoneBuffer: procedure expose status. mode.
address voicemail1 'flushPhoneBuffer'
return status.normal
listen: procedure expose status. mode.
address voicemail1 'listen'
return status.normal
answerFax: procedure expose status. mode.
address rexx 'handleFax'
return rc
cTime: procedure expose status. now mode.
address voicemail1 'ctime'
return result
displayError: procedure expose status. mode.
parse arg error
address voicemail1 'displayError' error
return status.normal
displayStatus: procedure expose status. mode.
parse arg status
address voicemail1 'displayStatus' status
return status.normal
displayMessage: procedure expose status. mode.
parse arg message
address voicemail1 'displayMessage' message
return status.normal
/* Effectively unlistens also! */
setLastError: procedure expose status. mode.
parse arg status, error
address voicemail1 'setLastError' status ',' error
return status.normal
showDebugger: procedure
parse arg debuggerInfo
firstLine = sourceline(1)
parse var firstLine '/*' title '*/'
if showlist('p', 'DEBUGGERLOGGER1') then
address debuggerLogger1 'e' title ':' debuggerInfo
else
say title ':' debuggerInfo
return
/*-----------------------------------------------------------------------*/
/* signal processing */
error:
call showDebugger("Error" rc "at line" sigl)
exit 20
break_c:
halt:
call showDebugger("Halt/Break_C at line" sigl)
exit 20
novalue:
call showDebugger("No value at line" sigl)
exit 20
syntax:
call showDebugger("Syntax error" rc "at line" sigl)
exit 20
/* Initialize everything needed to communicate correctly with ZVM */
doInitializations: procedure expose compression. mode. status. device. type. log.
log.incomingLog = 0
log.archiveLog = 1
log.outgoingLog = 2
log.outgoingArchiveLog = 3
/* compressions */
compression.ADPCM2 = 2
compression.ADPCM3 = 3
compression.CELP = 1
/* devices */
device.telephoneLine = 2
device.externalMic = 8
device.internalSpeaker = 16
/* file types */
type.unknownFile = 0
type.zvmRawFile = 1
type.zyxelFile = 2
type.iffFaxFile = 3
type.iff8svxFile = 4
/* modem modes */
mode.unknownMode = -1
mode.commandMode = 0
mode.voiceMode = 1
mode.connectedMode = 2
mode.playMode = 3
mode.recordMode = 4
/* return statuses from the various commands */
status.normal = 0
status.keyDetected = 1
status.quietDetected = 2
status.silenceDetected = 3
status.faxDetected = 4
status.busyDetected = 5
status.timedOut = 6
status.signalDetected = 7
status.overflow = 8
status.error = 9
call addlib("rexxsupport.library", 0, -30, 0)
return